#include "public.h"
#include "timer.h"
#include "led.h"

uint count = 0; //计数器
uint led_second = 0; //时间秒数

void timer0_demo() {
	if(count >= 100) {
		count = 0;
		if(++led_second > 256)
			led_second = 0;
		led_disp(led_second);
	}
}

void main() {
	sys_init();
	timer0_init();
	while(1) {
		timer0_demo();
	}
}

//T0中断服务函数
void timer0_isr() interrupt 1 {
	//记得重新赋初值
	TH0 = (65535-10000)/256;  //10ms
	TL0 = (65535-10000)%256;
	count++;
}

